'use strict';
//------------------------------------------------------------------------------------------------------------
//命令行处理
process.stdin.on('readable', ()=>{
    var chunk = process.stdin.read();
    if (chunk !== null) {
        var da = chunk.toString('utf8', 0, chunk.length - 2).split(' ');
        if (da[0] == 'reload') {
            //如\login\ext.js
            if (require.cache[__dirname + da[1]]) {
                var md = require(__dirname + da[1]);
                if (md.destroy) {
                    md.destroy();
                }
                delete require.cache[__dirname + da[1]];
                console.log(da[1] + ' cache is delete');
                require(__dirname + da[1]);
            } else {
                console.log(da[1] + ' not cache');
            }
        } else if(da[0] == 'eval'){
            da = da.slice(1);
            eval(da.join(" "));
        }
    }
});
process.stdin.on('end', function() {
    process.stdout.write('end');
});